<%
layout("/layouts/platform.html"){
%>
<header class="header navbar bg-white shadow">
    <div class="btn-group tool-button">
        <a class="btn btn-default navbar-btn" href="${base}/platform/wx/card" data-pjax  ><i class="ti-angle-left" id="goback"></i> 返回</a>
    </div>
</header>

<div class="content-wrap">
    <div class="wrapper" style="min-height:500px;height: 100%;">
            <form id="couponAddForm" role="form" class="form-horizontal parsley-form" data-parsley-validate 
                  action="${base}/platform/wx/card/addDo" method="post">
                <div class="row mb10">
                    <div class="col-lg-12">
                    	<div class="form-group">
                            <label for="card_type" class="col-sm-2 control-label">选择微信</label>
                            <div class="col-sm-8">
                                <select id="wxId" name="wxId" class="form-control" >
                                	<%for(config in obj){%>
                                		 <option value="${config.id}">${config.appname}</option>
                                	<%}%>
                                </select>
                            </div>
                        </div>
                    	<div class="form-group">
                            <label for="card_type" class="col-sm-2 control-label">卡券类型</label>
                            <div class="col-sm-8">
                                <select id="card_type" name="card_type" class="form-control" onchange="card_typeChange(this.value);">
                                    <option value="GROUPON">团购券</option>
                                    <option value="CASH">代金券</option>
                                    <option value="DISCOUNT">折扣券</option>
                                    <option value="GIFT">兑换券</option>
                                    <option value="GENERAL_COUPON">优惠券</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                        	<label for="logo_url" class="col-sm-2 control-label">logo</label>

                            <div class="col-sm-8">
                            	<div id="logo_url_queue"></div>
                                <div>
                                	<input id="logo_url_file_upload"  type="file" multiple="false">
                                </div>
                                <div id="logo_url_img" style="padding: 5px;"></div>
                                <input type="hidden" id="logo_url" name="logo_url" value="" >
                           	</div>
                       	</div>
                       	<div class="form-group">
                            <label for="brand_name" class="col-sm-2 control-label">商户名</label>

                            <div class="col-sm-8">
                                <input type="text" id="brand_name" class="form-control" name="brand_name" data-parsley-required="true" data-parsley-maxlength="12" placeholder="商户名">
                            </div>
                        </div>
                       	<div class="form-group">
                            <label for="title" class="col-sm-2 control-label">卡券名称</label>

                            <div class="col-sm-8">
                                <input type="text" id="title" class="form-control" name="title" data-parsley-required="true" data-parsley-maxlength="9" placeholder="卡券名称">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="sub_title" class="col-sm-2 control-label">券名</label>

                            <div class="col-sm-8">
                                <input type="text" id="sub_title" class="form-control" name="sub_title" data-parsley-required="true" data-parsley-maxlength="18" placeholder="券名">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="color" class="col-sm-2 control-label">颜色</label>

                            <div class="col-sm-8">
                                <select id="color" name="color" class="form-control" >
                                    <option value="Color010" style="background:#63b359 ">#63b359</option>
                                    <option value="Color020" style="background:#2c9f67 ">#2c9f67</option>
                                    <option value="Color030" style="background:#509fc9 ">#509fc9</option>
                                    <option value="Color040" style="background:#5885cf ">#5885cf</option>
                                    <option value="Color050" style="background:#9062c0 ">#9062c0</option>
                                    <option value="Color060" style="background:#d09a45 ">#d09a45</option>
                                    <option value="Color070" style="background:#e4b138 ">#e4b138</option>
                                    <option value="Color080" style="background:#ee903c ">#ee903c</option>
                                    <option value="Color081" style="background:#f08500 ">#f08500</option>
                                    <option value="Color082" style="background:#a9d92d ">#a9d92d</option>
                                    <option value="Color090" style="background:#dd6549 ">#dd6549</option>
                                    <option value="Color100" style="background:#cc463d ">#cc463d</option>
                                    <option value="Color101" style="background:#cf3e36 ">#cf3e36</option>
                                    <option value="Color102" style="background:#5E6671 ">#5E6671</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="card_fee" class="col-sm-2 control-label">额度</label>
                            
                            <div class="col-sm-8">
                                <input type="text" id="card_fee" class="form-control" name="card_fee" data-parsley-required="true" data-parsley-type="number" placeholder="额度(元/折扣)">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="notice" class="col-sm-2 control-label">使用提醒</label>
                            
                            <div class="col-sm-8">
                                <input type="text" id="notice" class="form-control" name="notice" data-parsley-required="true" data-parsley-maxlength="16"  placeholder="使用提醒，字数上限为16个汉字">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="description" class="col-sm-2 control-label">使用说明</label>
                            
                            <div class="col-sm-8">
                                <textarea rows="5" cols="5" id="description" class="form-control" name="description" data-parsley-required="true" data-parsley-maxlength="1024"  placeholder="使用说明，字数上限为1024个汉字"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="quantity" class="col-sm-2 control-label">库存</label>
                            
                            <div class="col-sm-8">
                                <input type="text" id="quantity" class="form-control" name="quantity" data-parsley-required="true" data-parsley-type="number" placeholder="库存">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="code_type" class="col-sm-2 control-label">Code展示类型</label>
                            
                            <div class="col-sm-8">
                                <select id="code_type" name="code_type" class="form-control" onchange="code_typeChange(this.value)">
                                    <option value="CODE_TYPE_TEXT">文本</option>
                                    <option value="CODE_TYPE_BARCODE">一维码</option>
                                    <option value="CODE_TYPE_QRCODE">二维码</option>
                                    <option value="CODE_TYPE_ONLY_QRCODE">二维码无code显示</option>
                                    <option value="CODE_TYPE_ONLY_BARCODE">一维码无code显示</option>
                                    <option value="CODE_TYPE_NONE" >自定义</option>
                                </select>
                            </div>
                        </div>
                        <div id="CODE_TYPE_NONE" style="display: none">
	                        <div class="form-group">
	                            <label for="custom_url_name" class="col-sm-2 control-label">自定义跳转外链名</label>
	                            
	                            <div class="col-sm-8">
	                                <input type="text" id="custom_url_name" class="form-control" name="custom_url_name" data-parsley-maxlength="10"  placeholder="自定义跳转外链名">
	                            </div>
	                        </div>
	                        <div class="form-group">
	                            <label for="custom_url_sub_title" class="col-sm-2 control-label">自定义跳转外链提示语</label>
	                            
	                            <div class="col-sm-8">
	                                <input type="text" id="custom_url_sub_title" class="form-control" name="custom_url_sub_title"  data-parsley-maxlength="20"  placeholder="自定义跳转外链提示语">
	                            </div>
	                        </div>
	                         <div class="form-group">
	                            <label for="custom_url" class="col-sm-2 control-label">自定义跳转外链URL</label>
	                            
	                            <div class="col-sm-8">
	                                <input type="text" id="custom_url" class="form-control" name="custom_url"  placeholder="自定义跳转外链URL">
	                            </div>
	                        </div>
	                         <div class="form-group">
	                            <label for="center_title" class="col-sm-2 control-label">中部按钮名</label>
	                            
	                            <div class="col-sm-8">
	                                <input type="text" id="center_title" class="form-control" name="center_title"  data-parsley-maxlength="10"  placeholder="中部按钮名">
	                            </div>
	                        </div>
	                         <div class="form-group">
	                            <label for="center_sub_title" class="col-sm-2 control-label">中部按钮提示语</label>
	                            
	                            <div class="col-sm-8">
	                                <input type="text" id="center_sub_title" class="form-control" name="center_sub_title" data-parsley-maxlength="16"  placeholder="中部按钮提示语">
	                            </div>
	                        </div>
	                         <div class="form-group">
	                            <label for="center_url" class="col-sm-2 control-label">中部按钮URL</label>
	                            
	                            <div class="col-sm-8">
	                                <input type="text" id="center_url" class="form-control" name="center_url"   placeholder="中部按钮URL">
	                            </div>
	                        </div>
	                          <div class="form-group">
	                            <label for="promotion_url_name" class="col-sm-2 control-label">营销自定义入口名</label>
	                            
	                            <div class="col-sm-8">
	                                <input type="text" id="promotion_url_name" class="form-control" name="promotion_url_name"  data-parsley-maxlength="10"  placeholder="营销自定义入口名">
	                            </div>
	                        </div>
	                         <div class="form-group">
	                            <label for="promotion_url_sub_title" class="col-sm-2 control-label">营销自定义提示语</label>
	                            
	                            <div class="col-sm-8">
	                                <input type="text" id="promotion_url_sub_title" class="form-control" name="promotion_url_sub_title"  data-parsley-maxlength="10"  placeholder="营销自定义提示语">
	                            </div>
	                        </div>
	                         <div class="form-group">
	                            <label for="promotion_url" class="col-sm-2 control-label">营销自定义URL</label>
	                            
	                            <div class="col-sm-8">
	                                <input type="text" id="promotion_url" class="form-control" name="promotion_url"  placeholder="营销自定义URL">
	                            </div>
	                        </div>
                        </div>
                        <div class="form-group">
                            <label for="type" class="col-sm-2 control-label">使用时间类型</label>
                            
                            <div class="col-sm-8">
                                <input type="radio" name="type" data-parsley-required="true" value="DATE_TYPE_FIX_TIME_RANGE" onclick="chooseDate(this.value)" />固定日期
                                <input type="radio" name="type" data-parsley-required="true" value="DATE_TYPE_FIX_TERM" onclick="chooseDate(this.value)" />固定时长
                            </div>
                        </div>
                        <div id="FIX_TIME_RANGE" style="display: none">
	                        <div class="form-group" >
	                           	<label for="begin_timestamp" class="col-sm-2 control-label">启用时间</label>
	                           	
	                            <div class="col-sm-3">
	                                <input type="text" id="begin_timestamp" name="begin_timestamp_str" value="" />
	                            </div>
	                        </div>
	                        <div class="form-group">
	                           <label for="end_timestamp" class="col-sm-2 control-label">结束时间</label>
	                           	
	                            <div class="col-sm-3">
	                                <input type="text" id="end_timestamp" name="end_timestamp_str" value="" />
	                            </div>
	                        </div>
                        </div>
                        <div class="form-group" id="FIX_TERM"  style="display: none">
                            <label for="fixed_term" class="col-sm-2 control-label">时长</label>
                            
                            <div class="col-sm-8">
                               <input type="text" id="fixed_term" class="form-control" name="fixed_term"  data-parsley-type="number" placeholder="时长（天）">
                               <input type="hidden"  name="fixed_begin_term"  value="0">
                            </div>
                        </div>
                        <div class="form-group" >
	                    	<label for="service_phone" class="col-sm-2 control-label">客服电话</label>
	                            
	                        <div class="col-sm-8">
	                 	       <input type="text"   id="service_phone" class="form-control" name="service_phone" placeholder="客服电话">
	                        </div>
	                    </div>
                        <div class="form-group" >
	                    	<label for="source" class="col-sm-2 control-label">第三方来源名</label>
	                            
	                        <div class="col-sm-8">
	                 	       <input type="text"   id="source" class="form-control" name="source" placeholder="第三方来源名">
	                        </div>
	                    </div>
                        <div class="form-group" >
	                    	<label for="get_limit" class="col-sm-2 control-label">每人领取数</label>
	                            
	                        <div class="col-sm-8">
	                 	       <input type="text"   id="get_limit" class="form-control" name="get_limit"  data-parsley-required="true"  data-parsley-type="number" placeholder="数量（张）">
	                        </div>
	                    </div>
	                    <div class="form-group">
                            <label for="can_share" class="col-sm-2 control-label">是否可分享</label>
                            
                            <div class="col-sm-8">
                                <input type="radio" name="can_share" data-parsley-required="true" value="true"  />是
                                <input type="radio" name="can_share" data-parsley-required="true" value="false" />否
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="can_share" class="col-sm-2 control-label">是否可转赠</label>
                            
                            <div class="col-sm-8">
                                <input type="radio" name="can_give_friend" data-parsley-required="true" value="true"  />是
                                <input type="radio" name="can_give_friend" data-parsley-required="true" value="false" />否
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="can_use_with_other_discount" class="col-sm-2 control-label">是否可与其他卡券共享</label>
                            
                            <div class="col-sm-8">
                                <input type="radio" name="can_use_with_other_discount" data-parsley-required="true" value="true"  />是
                                <input type="radio" name="can_use_with_other_discount" data-parsley-required="true" value="false" />否
                            </div>
                        </div>
                        <div id="CASH_DIV" style="display: none;">
	                        <div class="form-group">
	                            <label for="accept_category" class="col-sm-2 control-label">指定可用产品名</label>
	                            
	                            <div class="col-sm-8">
		                 	       <input type="text"   id="accept_category" class="form-control" name="accept_category"   placeholder="指定可用产品名，仅用于代金券类型">
		                        </div>
	                        </div>
	                        <div class="form-group">
	                            <label for="reject_category" class="col-sm-2 control-label">指定不可用产品名</label>
	                            
	                            <div class="col-sm-8">
		                 	       <input type="text"   id="reject_category" class="form-control" name="reject_category"    placeholder="指定可用产品名，仅用于代金券类型">
		                        </div>
	                        </div>
                        </div>
                        <div id="CASH_GIFT_DIV" style="display: none;">
	                        <div class="form-group">
	                            <label for="least_cost" class="col-sm-2 control-label">满减门槛</label>
	                            
	                            <div class="col-sm-8">
		                 	       <input type="text"   id="least_cost" class="form-control" name="least_cost"    placeholder="满减门槛字段，可用于兑换券和代金券">
		                        </div>
	                        </div>
	                    </div>
	                    <div id="GIFT_DIV" style="display: none;">
	                        <div class="form-group">
	                            <label for="object_use_for" class="col-sm-2 control-label">可用类型</label>
	                            
	                            <div class="col-sm-8">
		                 	       <input type="text"   id="object_use_for" class="form-control" name="object_use_for"    placeholder="购买xx可用类型门槛，仅用于兑换">
		                        </div>
	                        </div>
                        </div>
                        <div class="form-group">
                            <label for="abstractStr" class="col-sm-2 control-label">封面摘要简介</label>
                            
                            <div class="col-sm-8">
	                 	       <input type="text"   id="abstractStr" class="form-control" name="abstractStr"  data-parsley-required="true"  data-parsley-maxlength="20" placeholder="封面摘要简介">
	                        </div>
                        </div>
                        <div class="form-group">
                        	<label for="icon_url_list" class="col-sm-2 control-label">封面图片</label>

                            <div class="col-sm-8">
                            	<div id="icon_url_list_queue"></div>
                                <div>
                                	<input id="icon_url_list_file_upload"  type="file" multiple="false">
                                </div>
                                <div id="icon_url_list_img" style="padding: 5px;"></div>
                                <input type="hidden" id="icon_url_list" name="icon_url_list" value="" >
                           	</div>
                       	</div>
                        <div class="form-group">
                        	<label for="image_url" class="col-sm-2 control-label">详情图片</label>

                            <div class="col-sm-8">
                            	<div id="image_url_queue"></div>
                                <div>
                                	<input id="image_url_file_upload"  type="file" multiple="false">
                                </div>
                                <div id="image_url_img" style="padding: 5px;"></div>
                                <input type="hidden" id="image_url" name="image_url" value="" >
                           	</div>
                       	</div>
                       	<div class="form-group">
                            <label for="text" class="col-sm-2 control-label">详情简介</label>
                            
                            <div class="col-sm-8">
                             	<textarea rows="5" cols="5" id="text" class="form-control" name="text" data-parsley-required="true" data-parsley-maxlength="5000"  placeholder="详情简介，字数上限为5000个汉字"></textarea>
	                        </div>
                        </div>
                        <div class="form-group">
                        	<label for="image_url1" class="col-sm-2 control-label">详情图片</label>

                            <div class="col-sm-8">
                            	<div id="image_url1_queue"></div>
                                <div>
                                	<input id="image_url1_file_upload"  type="file" multiple="false">
                                </div>
                                <div id="image_url1_img" style="padding: 5px;"></div>
                                <input type="hidden" id="image_url1" name="image_url1" value="" >
                           	</div>
                       	</div>
                       	<div class="form-group">
                            <label for="text1" class="col-sm-2 control-label">详情简介</label>
                            
                            <div class="col-sm-8">
                             	<textarea rows="5" cols="5" id="text1" class="form-control" name="text1" data-parsley-required="true" data-parsley-maxlength="5000"  placeholder="详情简介，字数上限为5000个汉字"></textarea>
	                        </div>
                        </div>
                           <div class="form-group">
                        	<label for="image_url2" class="col-sm-2 control-label">详情图片</label>

                            <div class="col-sm-8">
                            	<div id="image_url2_queue"></div>
                                <div>
                                	<input id="image_url2_file_upload"  type="file" multiple="false">
                                </div>
                                <div id="image_url2_img" style="padding: 5px;"></div>
                                <input type="hidden" id="image_url2" name="image_url2" value="" >
                           	</div>
                       	</div>
                       	<div class="form-group">
                            <label for="text" class="col-sm-2 control-label">详情简介</label>
                            
                            <div class="col-sm-8">
                             	<textarea rows="5" cols="5" id="text2" class="form-control" name="text2" data-parsley-required="true" data-parsley-maxlength="5000"  placeholder="详情简介，字数上限为5000个汉字"></textarea>
	                        </div>
                        </div>
                        <div class="form-group">
                            <label for="remark" class="col-sm-2 control-label">说明</label>
                            
                            <div class="col-sm-8">
                             	<textarea rows="5" cols="5" id="remark" class="form-control" name="remark" data-parsley-required="true" data-parsley-maxlength="5000"  placeholder="说明"></textarea>
	                        </div>
                        </div>
                    </div>
                    <div class="col-lg-3"></div>
                	<div class="col-lg-6">
                    <div class="form-group text-center">
                        <label></label>
                        <div>
                        	<button class="btn btn-primary navbar-btn" type="button" id="save"> 保存</button>
                        </div>
                    </div>
                </div>
                </div>
            </form>
    </div>
</div>
<a class="exit-offscreen"></a>
<script language="JavaScript">
	function logo_url_clearFile() {
	    $("#logo_url_img").html("");
	    $("#logo_url_queue").html("");
	    $("#logo_url").val("");
	}
	function icon_url_list_clearFile() {
	    $("#icon_url_list_img").html("");
	    $("#icon_url_list_queue").html("");
	    $("#icon_url_list").val("");
	}
	function image_url_clearFile() {
	    $("#image_url_img").html("");
	    $("#image_url_queue").html("");
	    $("#image_url").val("");
	}
	function image_url1_clearFile() {
	    $("#image_url1_img").html("");
	    $("#image_url1_queue").html("");
	    $("#image_url1").val("");
	}
	function image_url2_clearFile() {
	    $("#image_url2_img").html("");
	    $("#image_url2_queue").html("");
	    $("#image_url2").val("");
	}
    $(document).ready(function () {
    	$.datetimepicker.setLocale('ch');
        $('#begin_timestamp').datetimepicker({
         	lang:'ch',
         	format:'Y-m-d H:i:s'
        });
        $('#end_timestamp').datetimepicker({
         	lang:'ch',
         	format:'Y-m-d H:i:s'
        });
    	$('#logo_url_file_upload').uploadifive({
             'auto': true,
             'multi': false,
             'width': '100%',
             'height': '35',
             'buttonText': '请选择图片',
             'fileType': 'image/*',
             'fileSizeLimit': 1024,
             'queueSizeLimit': 1,
             'formData': {},
             'queueID': 'logo_url_queue',
             'uploadScript': '${base}/open/file/upload/image',
             'onUploadComplete': function (file, data) {
                 data = JSON.parse(data);
                 if (data.code == 0) {
                     Toast.success(data.msg);
                     $("#logo_url_img").html("<img src='${AppUploadRoot}" + data.data + "' style='width:150px;height:95px;'>");
                     $("#logo_url").val(data.data);
                 } else {
                	 logo_url_clearFile();
                     Toast.error(data.msg);
                 }
             },
             'onDrop': function (file, fileDropCount) {
            	 logo_url_clearFile();
             },
             'onClearQueue': function (queue) {
            	 logo_url_clearFile();
             },
             'onCancel': function () {
            	 logo_url_clearFile();
             }
         });
    	$('#icon_url_list_file_upload').uploadifive({
            'auto': true,
            'multi': false,
            'width': '100%',
            'height': '35',
            'buttonText': '请选择图片',
            'fileType': 'image/*',
            'fileSizeLimit': 1024,
            'queueSizeLimit': 1,
            'formData': {},
            'queueID': 'icon_url_list_queue',
            'uploadScript': '${base}/open/file/upload/image',
            'onUploadComplete': function (file, data) {
                data = JSON.parse(data);
                if (data.code == 0) {
                    Toast.success(data.msg);
                    $("#icon_url_list_img").html("<img src='${AppUploadRoot}" + data.data + "' style='width:150px;height:95px;'>");
                    $("#icon_url_list").val(data.data);
                } else {
                	icon_url_list_clearFile();
                    Toast.error(data.msg);
                }
            },
            'onDrop': function (file, fileDropCount) {
            	icon_url_list_clearFile();
            },
            'onClearQueue': function (queue) {
            	icon_url_list_clearFile();
            },
            'onCancel': function () {
            	icon_url_list_clearFile();
            }
        });
    	
     	$('#image_url_file_upload').uploadifive({
            'auto': true,
            'multi': false,
            'width': '100%',
            'height': '35',
            'buttonText': '请选择图片',
            'fileType': 'image/*',
            'fileSizeLimit': 1024,
            'queueSizeLimit': 1,
            'formData': {},
            'queueID': 'image_url_queue',
            'uploadScript': '${base}/open/file/upload/image',
            'onUploadComplete': function (file, data) {
                data = JSON.parse(data);
                if (data.code == 0) {
                    Toast.success(data.msg);
                    $("#image_url_img").html("<img src='${AppUploadRoot}" + data.data + "' style='width:150px;height:95px;'>");
                    $("#image_url").val(data.data);
                } else {
                	image_url_clearFile();
                    Toast.error(data.msg);
                }
            },
            'onDrop': function (file, fileDropCount) {
            	image_url_clearFile();
            },
            'onClearQueue': function (queue) {
            	image_url_clearFile();
            },
            'onCancel': function () {
            	image_url_clearFile();
            }
        });
     	$('#image_url1_file_upload').uploadifive({
            'auto': true,
            'multi': false,
            'width': '100%',
            'height': '35',
            'buttonText': '请选择图片',
            'fileType': 'image/*',
            'fileSizeLimit': 1024,
            'queueSizeLimit': 1,
            'formData': {},
            'queueID': 'image_url1_queue',
            'uploadScript': '${base}/open/file/upload/image',
            'onUploadComplete': function (file, data) {
                data = JSON.parse(data);
                if (data.code == 0) {
                    Toast.success(data.msg);
                    $("#image_url1_img").html("<img src='${AppUploadRoot}" + data.data + "' style='width:150px;height:95px;'>");
                    $("#image_url1").val(data.data);
                } else {
                	image_url1_clearFile();
                    Toast.error(data.msg);
                }
            },
            'onDrop': function (file, fileDropCount) {
            	image_url1_clearFile();
            },
            'onClearQueue': function (queue) {
            	image_url1_clearFile();
            },
            'onCancel': function () {
            	image_url1_clearFile();
            }
        });
     	$('#image_url2_file_upload').uploadifive({
            'auto': true,
            'multi': false,
            'width': '100%',
            'height': '35',
            'buttonText': '请选择图片',
            'fileType': 'image/*',
            'fileSizeLimit': 1024,
            'queueSizeLimit': 1,
            'formData': {},
            'queueID': 'image_url2_queue',
            'uploadScript': '${base}/open/file/upload/image',
            'onUploadComplete': function (file, data) {
                data = JSON.parse(data);
                if (data.code == 0) {
                    Toast.success(data.msg);
                    $("#image_url2_img").html("<img src='${AppUploadRoot}" + data.data + "' style='width:150px;height:95px;'>");
                    $("#image_url2").val(data.data);
                } else {
                	image_url2_clearFile();
                    Toast.error(data.msg);
                }
            },
            'onDrop': function (file, fileDropCount) {
            	image_url2_clearFile();
            },
            'onClearQueue': function (queue) {
            	image_url2_clearFile();
            },
            'onCancel': function () {
            	image_url2_clearFile();
            }
        });
    	
    	$("#save").on("click",function(){
            // $('#couponAddForm').submit();
    		$.ajax({
    			url : "${base}/platform/wx/card/addDo",
    			data: $("#couponAddForm").serialize(),
    			type : "post",
    			async : false,
    			dataType : "json",
    			success : function(data){
    				if (data.code==0) {
                   	 Toast.success(data.msg);
                        setTimeout(function () {
                            $("#goback").trigger("click");
                        }, 1000);
                   } else {
                       Toast.error(data.msg);
                       setTimeout(function () {
                           $("#goback").trigger("click");
                       }, 1000);
                   }
    			}
    		});
         }); 
    });
    
    //卡券类型
    function card_typeChange(value){
    	if(value=="CASH"){
    		$("#CASH_DIV").css('display','block'); 
    		$("#CASH_GIFT_DIV").css('display','block'); 
    		$("#GIFT_DIV").css('display','none'); 
    		 
    		$("#reject_category").attr('data-parsley-required','true'); 
    		$("#least_cost").attr('data-parsley-required','true'); 
    		$("#object_use_for").removeAttr('data-parsley-required'); 
    		
    		$("#object_use_for").val("");
    		
    		
    	}else if(value=="GIFT"){
    		$("#CASH_DIV").css('display','none'); 
    		$("#CASH_GIFT_DIV").css('display','block'); 
    		$("#GIFT_DIV").css('display','block'); 
    		
    		$("#least_cost").attr('data-parsley-required','true'); 
    		$("#object_use_for").attr('data-parsley-required','true'); 
    		$("#reject_category").removeAttr('data-parsley-required'); 
    		$("#reject_category").val("");
    	}else{
    		$("#CASH_DIV").css('display','none'); 
    		$("#CASH_GIFT_DIV").css('display','none'); 
    		$("#GIFT_DIV").css('display','none');
    		
    		$("#reject_category").removeAttr('data-parsley-required'); 
    		$("#least_cost").removeAttr('data-parsley-required'); 
    		$("#object_use_for").removeAttr('data-parsley-required');
    		
    		$("#object_use_for").val("");
    		$("#least_cost").val("");
    		$("#reject_category").val("");
    	}
    }
    //使用时间类型
    function chooseDate(value){
    	if(value=="DATE_TYPE_FIX_TIME_RANGE"){
    		$("#FIX_TIME_RANGE").css('display','block'); 
    		$("#FIX_TERM").css('display','none'); 
    		$("#fixed_term").removeAttr('data-parsley-required'); 
    		
    		//清空数据
    		$("#fixed_term").val("");
    	}
    	if(value=="DATE_TYPE_FIX_TERM"){
    		$("#FIX_TERM").css('display','block'); 
    		$("#FIX_TIME_RANGE").css('display','none'); 
    		$("#fixed_term").attr('data-parsley-required','true'); 
    		//清空数据
    		$("#begin_timestamp").val("");
    		$("#end_timestamp").val("");
    	}
    }
    // code显示类型
    function code_typeChange(value){
    	if(value=="CODE_TYPE_NONE"){
    		$("#CODE_TYPE_NONE").css('display','block'); 
    		$("#custom_url_name").attr('data-parsley-required','true'); 
    		$("#custom_url").attr('data-parsley-required','true'); 
    		$("#center_title").attr('data-parsley-required','true'); 
    		$("#center_url").attr('data-parsley-required','true'); 
    	}else{
    		$("#CODE_TYPE_NONE").css('display','none');
    		
    		$("#custom_url_name").removeAttr('data-parsley-required'); 
    		$("#custom_url").removeAttr('data-parsley-required'); 
    		$("#center_title").removeAttr('data-parsley-required'); 
    		$("#center_url").removeAttr('data-parsley-required'); 
    		//清空数据
    		$("#custom_url_name").val("");
    		$("#custom_url").val("");
    		$("#custom_url_sub_title").val("");
    		$("#center_title").val("");
    		$("#center_sub_title").val("");
    		$("#center_url").val("");
    		$("#promotion_url_name").val("");
    		$("#promotion_url").val("");
    		$("#promotion_url_sub_title").val("");
    	}
    }
    
  
</script>
<%}%>